/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.flexengine.component;

/**
 * @author Luann R. Athayde
 * @version 1.0
 * @since 1.0
 */
public class StatusLabel extends Label {

    private String basicText;
    
    private int    count = 0;
    private int    dots  = 0;
    private boolean showDots = true;
    
    public StatusLabel() {
        this("");
    }
    
    public StatusLabel(String text) {
        super(text);
        basicText = text;
    }

    @Override
    public void update(Long time, Long totalTime) {
        super.update(time, totalTime); //To change body of generated methods, choose Tools | Templates.
        if( showDots ) {
            count++;
            if( count >= 25 ) {
                dots++;
                if( dots == 4 ) {
                    dots = 0;
                }
                setText(basicText+getDots());
                count = 0;
            }
        } else {
            setText(basicText);
        }
    }

    public boolean isShowDots() {
        return showDots;
    }

    public void setShowDots(boolean showDots) {
        this.showDots = showDots;
    }
    
    private String getDots() {
        String strDots = "";
        for(int i=0;i<dots;i++) {
            strDots += ".";
        }
        return strDots;
    }

    public String getBasicText() {
        return basicText;
    }

    public void setBasicText(String basicText) {
        this.basicText = basicText;
    }
    
}
